import Vue from 'vue';
import VueRouter from 'vue-router';
import store from "./store.js";
import Frame from "../src/components/frame.vue";

import {
	RouterTabRoutes
} from 'vue-router-tab';

const importPage = view => () =>
	import(`../page/${view}.vue`)

Vue.use(VueRouter);

const pageRouters = [{
		path: '/', // 默认页和父级路由一致
		name: 'main',
		component: importPage('main'),
		meta: {
			title: '工作台' // 页签标题
		}
	},
	{
		path: '/user',
		name: 'user',
		component: importPage('user/list'),
		meta: {
			title: '用户列表' // 页签标题
		}
	},
	{
		path: '/role',
		name: 'role',
		component: importPage('role/list'),
		meta: {
			title: '角色列表' // 页签标题
		}
	},
	{
		path: '/permission',
		name: 'permission',
		component: importPage('permission/list'),
		meta: {
			title: '权限列表' // 页签标题
		}
	},

	{
		path: '/dept',
		name: 'dept',
		component: importPage('dept/list'),
		meta: {
			title: '部门列表' // 页签标题
		}
	},
	{
		path: '/dept/info',
		name: 'dept_info',
		component: importPage('dept/detail'),
		meta: {
			title: '部门详细' // 页签标题
		}
	},

	{
		path: '/emp',
		name: 'emp',
		component: importPage('emp/list'),
		meta: {
			title: '员工列表' // 页签标题
		}
	},
	{
		path: '/emp/info',
		name: 'emp_info',
		component: importPage('emp/detail'),
		meta: {
			title: '员工详细' // 页签标题
		}
	},
	{
		path: '/job/list',
		name: 'job_list',
		component: importPage('job/list'),
		meta: {
			title: '职位详细' // 页签标题
		}
	},
	
	
	/* 门店管理菜单配置 开始 20250211 09:21:30 by cailongyang */
	
	//门店列表
	{
		path: '/md',
		name: 'md',
		component: importPage('md/list'),
		meta: {
			title: '门店列表' // 页签标题
		}
	},
	{
		path: '/md/new',
		name: 'md_new',
		component: importPage('md/new'),
		meta: {
			title: '门店新增' // 页签标题
		}
	},
	{
		path: '/md/detail',
		name: 'md_detail',
		component: importPage('md/detail'),
		meta: {
			title: '门店详细' // 页签标题
		}
	},
	
	//房间列表
	{
		path: '/fj',
		name: 'fj',
		component: importPage('fj/list'),
		meta: {
			title: '房间列表' // 页签标题
		}
	},
	{
		path: '/fj/new',
		name: 'fj_new',
		component: importPage('fj/new'),
		meta: {
			title: '房间新增' // 页签标题
		}
	},
	{
		path: '/fj/detail',
		name: 'fj_detail',
		component: importPage('fj/detail'),
		meta: {
			title: '房间详细' // 页签标题
		}
	},
	
	//设备列表
	{
		path: '/sb',
		name: 'sb',
		component: importPage('sb/list'),
		meta: {
			title: '设备列表' // 页签标题
		}
	},
	{
		path: '/sb/new',
		name: 'sb_new',
		component: importPage('sb/new'),
		meta: {
			title: '设备新增' // 页签标题
		}
	},
	{
		path: '/sb/detail',
		name: 'sb_detail',
		component: importPage('sb/detail'),
		meta: {
			title: '设备详细' // 页签标题
		}
	},
	/* 门店管理菜单配置 结束 20250211 09:21:30 by cailongyang */
	
	
	
	
	/* 客户管理菜单配置 开始 20250211 09:21:30 by cailongyang */
	//客户列表
	{
		path: '/kh',
		name: 'kh',
		component: importPage('kh/list'),
		meta: {
			title: '客户列表' // 页签标题
		}
	},
	{
		path: '/kh/detail',
		name: 'kh_detail',
		component: importPage('kh/detail'),
		meta: {
			title: '客户详细' // 页签标题
		}
	},
	
	//会员列表
	{
		path: '/hy',
		name: 'hy',
		component: importPage('hy/list'),
		meta: {
			title: '会员列表' // 页签标题
		}
	},
	{
		path: '/hy/detail',
		name: 'hy_detail',
		component: importPage('hy/detail'),
		meta: {
			title: '会员详细' // 页签标题
		}
	},
	/* 客户管理菜单配置 结束 20250211 09:21:30 by cailongyang */
	
	
	
	/* 商品管理菜单配置 开始 20250211 09:21:30 by cailongyang */
	
	//会员类型列表
	{
		path: '/hyt',
		name: 'hyt',
		component: importPage('hyt/list'),
		meta: {
			title: '会员类型列表' // 页签标题
		}
	},
	
	//商品列表
	{
		path: '/sp',
		name: 'sp',
		component: importPage('sp/list'),
		meta: {
			title: '商品列表' // 页签标题
		}
	},
	
	/* 商品管理菜单配置 结束 20250211 09:21:30 by cailongyang */
	
	
	/* 订单管理菜单配置 开始 20250211 09:21:30 by cailongyang */
	//订单列表
	{
		path: '/dd',
		name: 'dd',
		component: importPage('dd/list'),
		meta: {
			title: '订单列表' // 页签标题
		}
	},
	{
		path: '/dd/detail',
		name: 'dd_detail',
		component: importPage('dd/detail'),
		meta: {
			title: '订单详细' // 页签标题
		}
	},
	
	/* 订单管理菜单配置 结束 20250211 09:21:30 by cailongyang */
];





const detailRouters = {
	'user_new': {
		name: 'user_new',
		component: importPage('user/new'),
		meta: {
			title: '用户新增' // 页签标题
		}
	},
	'user_detail': {
		name: 'user_detail',
		component: importPage('user/detail'),
		meta: {
			title: '用户详情', // 页签标题
		}
	},
	'role_new': {
		name: 'role_new',
		component: importPage('role/new'),
		meta: {
			title: '新增角色' // 页签标题
		}
	},
	'role_detail': {
		name: 'role_detail',
		component: importPage('role/detail'),
		meta: {
			title: '角色详细' // 页签标题
		}
	},
	'permission_new': {
		name: 'permission_new',
		component: importPage('permission/new'),
		meta: {
			title: '新增权限' // 页签标题
		}
	},
	'permission_detail': {
		name: 'permission_detail',
		component: importPage('permission/detail'),
		meta: {
			title: '权限详细' // 页签标题
		}
	},

	'dept_new': {
		name: 'dept_new',
		component: importPage('dept/new'),
		meta: {
			title: '新增部门' // 页签标题
		}
	},
	'job_detail': {
		name: 'job_detail',
		component: importPage('job/detail'),
		meta: {
			title: '职位详细' // 页签标题
		}
	},
	'job_new': {
		name: 'job_new',
		component: importPage('job/new'),
		meta: {
			title: '职位新增' // 页签标题
		}
	},


	'flow_new': {
		name: 'flow_new',
		component: importPage('flow/new'),
		meta: {
			title: '新增流程' // 页签标题
		}
	},

	'flow_detail': {
		name: 'flow_detail',
		component: importPage('flow/detail'),
		meta: {
			title: '模板详细' // 页签标题
		}
	},

	'emp_new': {
		name: 'emp_new',
		component: importPage('emp/new'),
		meta: {
			title: '新增员工' // 页签标题
		}
	},
	
	
	
	/* 门店管理菜单配置 开始 20250211 09:21:30 by cailongyang */
	'mj_new': {
		name: 'mj_new',
		component: importPage('md/mjnew'),
		meta: {
			title: '新增门禁' // 页签标题
		}
	},
	'mj_detail': {
		name: 'mj_detail',
		component: importPage('md/mjdetail'),
		meta: {
			title: '门禁详细' // 页签标题
		}
	},
	/* 门店管理菜单配置 结束 20250211 09:21:30 by cailongyang */
	
	/* 商品管理菜单配置 开始 20250211 09:21:30 by cailongyang */
	'hyt_new': {
		name: 'hyt_new',
		component: importPage('hyt/new'),
		meta: {
			title: '新增会员类型' // 页签标题
		}
	},
	'hyt_detail': {
		name: 'hyt_detail',
		component: importPage('hyt/detail'),
		meta: {
			title: '新增会员详细' // 页签标题
		}
	},
	
	'sp_new': {
		name: 'sp_new',
		component: importPage('sp/new'),
		meta: {
			title: '商品类型' // 页签标题
		}
	},
	'sp_detail': {
		name: 'sp_detail',
		component: importPage('sp/detail'),
		meta: {
			title: '商品详细' // 页签标题
		}
	},
	
	/* 商品管理菜单配置 结束 20250211 09:21:30 by cailongyang */
};


const routes = [{
	path: '/',
	component: Frame,
	meta: {
		title: '主页' // 页签标题
	},
	children: pageRouters
}];

const router = new VueRouter({
	routes,
	pageRouters,
	detailRouters
});

router.detail = {
	open: param => {
		store.commit("openDetail", param);
	},
	close: param => {
		store.commit("closeDetail");
	}
}

const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
	return originalPush.call(this, location).catch(err => err)
}

export default router;
